<template>
	<view class="beijingse" v-if="pageShow">
		<view class="zzdbbox">
			<view class="strongtext xiaobai fonweight">可提现</view>
			<view class="sishi xiaobai margin_top2 fonweight">￥
				<text class="xiaobai fonweight" style="font-size: 70rpx;"  v-if="type==1">{{userInfo.money}}</text>
				<text class="xiaobai fonweight" style="font-size: 70rpx;"  v-if="type==2">{{userInfo.yjbzj_price}}</text>
			</view>
		</view>
		<view class="mainpadding" style="position: relative; top: -110rpx;">
			<view class="ffffff radius mainpadding">
				<view class="ershiba xiaohei">提现金额（元）</view>
				<view class="flexbetween margin_top2">
					<view class="flexleft">
						<view class="sishi xiaohei margin_top2 fonweight">￥</view>
						<input type="digit" v-model="money" class="fonweight"
							style="font-size: 64rpx;height: 80rpx;" />
					</view>
					<view class="ershiba xiaocheng" style="min-width: 150rpx;" v-if="type==1" @click="money=userInfo.money">全部提现</view>
					<view class="ershiba xiaocheng" style="min-width: 150rpx;" v-if="type==2" @click="money=userInfo.yjbzj_price">全部提现</view>
				</view>
			</view>
			<view class="mainpadding radius ffffff margin_top">
				<view class="ershiba zhonghei">提现至</view>
				<view class="flexbetween margin_top">
					<view class="flexleft">
						<view class="margin_right1">
							<u-icon name="weixin-circle-fill" color="#28C445" size="22"></u-icon>
						</view>
						<view class="ershiba xiaohei">提现至</view>
					</view>
					<u-icon name="checkmark-circle-fill" color="#FF9341" size="18"></u-icon>
				</view>
			</view>
			<view class="bigbtn " style="margin-top: 180rpx;" @click="submit">提现</view>
			<view class="xiaocheng textcenter margin_top sanshier" v-if="type==1" @click="tzzjl">提现记录</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")

	export default {
		data() {
			return {
				userInfo: {},
				pageShow: true,
				shop_id: "",
				money:"",
				openid:"",
				type:1,//1我的店铺余额提现，2保证金提现
			}
		},
		onLoad(options) {
			this.shop_id = options.id
			this.type=options.type
			// #ifdef MP-WEIXIN
			this.wxLogin()
			// #endif
		},
		onShow() {
			this.userinfomsg()
		},
		methods: {
			wxLogin() {
				let _this = this
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				uni.login({
					success(res) {
						if (res.code) {
							_this.code = res.code
							uni.setStorageSync('code', res.code);
							httpRequest.request('/api/user/getopenid', 'GET', {
								code:res.code
							}).then(resp => {
								uni.hideLoading()
								_this.openid = resp.data.openid
							})
						}
					}
				})
			},
			userinfomsg() {
				httpRequest.request('/api/shopcl/myShopDetail', 'GET', {
					shop_id: this.shop_id
				}).then(res => {
					this.pageShow = true
					this.userInfo = res.data
				})
			},
			submit() {
				if (this.money == "") {
					httpRequest.toast("请输入提现金额")
					return false
				}
				uni.showLoading({
					mask: true,
					title: "请稍后"
				})
				let url = "/api/shopcl/withdrawal"
				if(this.type==2){
					url = "/api/shopcl/bzjWithdrawal"
				}
				httpRequest.request(url, 'GET', {
					shop_id:this.shop_id,
					money: this.money,
					openid: this.openid,
				}).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if (res.code == 1) {
						setTimeout(() => {
							uni.navigateBack(1)
						}, 500)
					}
				})
			},
			// 跳转转账记录
			tzzjl() {
				uni.navigateTo({
					url: '/pages_wode/tixianjl?id='+this.shop_id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zzdbbox {
		background-size: 100% 100%;
		padding: 16rpx 30rpx 100rpx;
		background-image: url('https://kuaixun.yuntaiqikeji.com/uploads/20240115/72aba476733bb7cd89b5910c897ea17b.png');
	}
</style>